﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AresCustomYacht
{
    public partial class P_WorkTask : System.Web.UI.Page
    {
        readonly BL _bl = new BL();
        protected void Page_Load(object sender, EventArgs e)
        {
            var typeId = int.Parse(Utility.GetQueryStringItem(this, "WorkType"));
            Utility.DisplayPageMessage(this,lblMessage);
            if (!Page.IsPostBack)
            {
                var tasks = _bl.GetTypeTasks(typeId);
                lstTask.DataSource = tasks;
                lstTask.DataTextField = "Name";
                lstTask.DataValueField = "Id";
                lstTask.DataBind();
            }

            lstTask.SelectedIndex = 0;

        }

        protected void lstTask_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var boatId = int.Parse(Utility.GetQueryStringItem(this, "BoatId"));
            var message = Utility.GetQueryStringItem(this, "Message");
            var linkAddress =
                Utility.Encrypt("Mode=0&BoatId=" + boatId + "&WorkTask=" + lstTask.SelectedValue + "&Message=" + message + ">" + lstTask.SelectedItem.Text);
            Response.Redirect("Track.aspx?k=" + linkAddress);
        }
    }
}